package com.fishery.message.utils;

import com.fasteat.common.entity.GlobalException;
import com.fasteat.common.entity.Result;
import com.fasteat.common.entity.StatusCode;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * ip地址工具类
 * @Author hy
 * @Date 2020--1-14
 */
public class IpAddressUtil {
	public static String getIpAdrress(HttpServletRequest request) {
		String ip = request.getHeader("xip");
		if (StringUtils.isEmpty(ip)) {
			throw new GlobalException(Result.error(StatusCode.ERROR, "非法访问"));
		}
		return ip;
	}
}

